package com.share51.novel.security;

import com.share51.novel.security.interceptor.CommonInterceptor;
import com.share51.novel.security.interceptor.SecurityInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * 安全配置 注册拦截器
 * @author gb
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Resource
    private SecurityInterceptor securityInterceptor;

    @Resource
    private CommonInterceptor commonInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry
                .addInterceptor(securityInterceptor)
                .addPathPatterns(SecurityInterceptor.PATH_URL)
                .excludePathPatterns(SecurityInterceptor.EXCLUDE_PATH_URL);

        registry.addInterceptor(commonInterceptor)
                .addPathPatterns(CommonInterceptor.PATH_URL)
                .excludePathPatterns(CommonInterceptor.EXCLUDE_PATH_URL);

    }
}
